﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Qianke.Core.Common
{
    public class ReturnInfo
    {
        public string resultcode { set; get; }

        public string resultcontent { set; get; }

        public ReturnInfo()
        {
            resultcode = "200";
            resultcontent = "操作成功";
        }

        private static ReturnInfo _success = new ReturnInfo();
        public static ReturnInfo Success
        {
            get { return _success; }
        }

        public ReturnInfo(string strCode, string strContent)
        {
            resultcode = strCode;
            resultcontent = strContent;
        }

        public override string ToString()
        {
            return this.ToJson();
        }
    }

    public class ReturnInfoData<T> : ReturnInfo
    {
        public T data { set; get; }

        public ReturnInfoData() : base()
        {

        }

        public ReturnInfoData(T data) : base()
        {
            this.data = data;
        }

        public ReturnInfoData(string strCode, string strContent)
            : base(strCode, strContent)
        {

        }
        public ReturnInfoData(string strCode, string strContent, T data)
            : base(strCode, strContent)
        {
            this.data = data;
        }
    }

    public class ReturnInfoData : ReturnInfoData<object>
    {

        public ReturnInfoData() : base()
        {

        }

        public ReturnInfoData(object data) : base()
        {
            this.data = data;
        }

        public ReturnInfoData(string strCode, string strContent)
            : base(strCode, strContent)
        {

        }
        public ReturnInfoData(string strCode, string strContent, object data)
            : base(strCode, strContent, data)
        {
            var p = data as Exception;
            if (p != null)
                this.data = p.ToString();
            else
                this.data = data;
        }
    }



    public class ReturnInfoPageData : ReturnInfoData<object>
    {
        public int totalRows { get; set; }

        public ReturnInfoPageData() : base()
        {

        }

        public ReturnInfoPageData(int totalRows, object data) : base()
        {
            this.totalRows = totalRows;
            this.data = data;
        }

        public ReturnInfoPageData(string strCode, string strContent)
            : base(strCode, strContent)
        {

        }

        public ReturnInfoPageData(string strCode, string strContent, int totalRows, object data)
            : base(strCode, strContent,data)
        {
            this.totalRows = totalRows;
        }
    }
}
